home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Source Code
/
PowerPlant
/
Slider
/
SliderTestView.cp
< prev
next >
Wrap
Text File
|
1995-04-27
|
3KB
|
122 lines
//
// ===========================================================================
// SliderTestView.cp ©1995 Scott Squires
// ===========================================================================
//
// Subclass of LView to demo Slider.cp
// Real application would probably have a view that stored the Slider pointers
// and then used them to 'GetSliderValue()' in a DrawSelf().
// Currently the display is only updated when the sliders are moved
#define StdHorzSliderID 2002
#define GraySliderID 2003
#define BulbSliderID 2004
#define CloudSliderID 2005
#define BearSliderID 2006
#define StdVertSliderID 2007
#include "SliderTestView.h"
#include <LView.h>
#include <LListener.h>
#include "Slider.h"
SliderView::SliderView()
: LView()
{
}
SliderView::SliderView(LStream *inStream)
: LView(inStream)
{
}
SliderView *SliderView::CreateSliderTestStream(LStream *inStream)
{
return (new SliderView(inStream));
}
SliderView::~SliderView()
{
}
void SliderView::ListenToMessage(MessageT inMessage, void *ioParam)
{
Str255 theNum;
Rect tempRect, box;
RGBColor tempColor, BlackRGB;
BlackRGB.red = 0;
BlackRGB.green = 0;
BlackRGB.blue = 0;
FocusDraw();
TextMode(srcCopy);
TextFont(4);
switch (inMessage) {
// Message sent from Slider when value is updated
// In this demo most values are just displayed
case StdHorzSliderID:
NumToString(*(long *)ioParam, theNum);
SetRect(&box, 215, 10, 245, 30);
TextBox(theNum + 1, theNum[0], &box, teFlushRight);
break;
case GraySliderID:
NumToString(*(long *)ioParam, theNum);
SetRect(&box, 215, 75, 245, 95);
TextBox(theNum + 1, theNum[0], &box, teFlushRight);
break;
case BulbSliderID:
NumToString(*(long *)ioParam, theNum);
SetRect(&box, 215, 117, 245, 137);
TextBox(theNum + 1, theNum[0], &box, teFlushRight);
break;
case CloudSliderID:
NumToString(*(long *)ioParam, theNum);
SetRect(&box, 215, 155, 245, 175);
TextBox(theNum + 1, theNum[0], &box, teFlushRight);
break;
case BearSliderID:
NumToString(*(long *)ioParam, theNum);
SetRect(&box, 215, 213, 245, 233);
TextBox(theNum + 1, theNum[0], &box, teFlushRight);
break;
case StdVertSliderID:
// Vertical slider controls a colored square
NumToString(*(long *)ioParam, theNum);
SetRect(&box, 275, 30, 320, 50);
TextBox(theNum + 1, theNum[0], &box, teFlushRight);
SetRect(&tempRect, 275, 50, 325, 100);
tempColor.red = 0;
tempColor.green = *(long *)ioParam;
tempColor.blue = 0;
RGBForeColor(&tempColor);
PaintRect(&tempRect);
RGBForeColor(&BlackRGB);
break;
}
}